<extend name="public:template" />
<block name="title">菜单列表</block>
<block name="style">
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css" type="text/css">
</block>
<block name="content">

    <div class="wrap-page">
        <div id="pageBookList" class="page-content">
            <Admintemplate file="Common/SubTabs"/>
            <div id="boxBookList" class="box">
                <div class="box-content">
                    <div class="wrap-table">
                        <div class="table-bar table-bar-head clearfix">
                            <div class="fl-l">
                                <div class="tools">
                                    <span class="tool-item"><a class="button button-blue" href="{:U('backend/menu/add')}">添加菜单</a></span>
                                    <span class="tool-item"><a class="button button-red btn-delete-batch" href="javascript:;" data-url="{:U('backend/menu/delete')}">删除所选</a></span>
                                </div>
                            </div>
                            <div class="fl-r">
                                <div class="tools">
                                    <span class="tool-item"><button onclick="javascript:window.location.replace(window.location.href);" class="button button-default" type="button">刷新列表</button></span>
                                </div>
                            </div>
                        </div>
                            <table class="table default-style" cellpadding="0" cellspacing="0" width="100%">
                                <thead>
                                <tr>
                                    <th width="40"><input type="checkbox" name="checkall" class="J_checkall"></th>
                                    <th width="40"><span tdtype="order_by" fieldname="id">ID</span></th>
                                    <th>{:L('menu_name')}</th>
                                    <th><span tdtype="order_by" fieldname="ordid">{:L('sort_order')}</span></th>
                                    <th width="160">{:L('operations_manage')}</th>
                                </tr>
                                </thead>
                                <tbody>
                                {$menu_list}
                                </tbody>
                            </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</block>
<block name="script">
    <script>
        $(function(){


            $('.allbtn').click(function(){
                var obj = $(this);
                var ids ='';
                var field = obj.attr('data-name');
                $('.J_checkitem').each(function(){
                    if($(this).attr('checked') == 'checked')
                    {
                        ids += $(this).val() + ',';
                    }
                });
                ids = ids.substr(0, (ids.length - 1));
                if(!$.trim(ids))
                {
                    layer.msg('请至少选择一个操作项');
                    return false;
                }
                layer.confirm($(this).attr('data-msg'),{},function(index)
                {
                    $.ajax({
                        type: 'post',
                        data: {id:ids, field:field},
                        dataType: 'json',
                        url : obj.attr('data-uri'),
                        success: function(data){
                            if(!data.status)
                            {
                                layer.msg(data.msg,{icon:2,time:2000});
                            } else {
                                layer.msg(data.msg,{icon:1,time:2000},function(){
                                    window.location.reload();
                                });
                            }
                            layer.close(index);
                        }
                    });
                    return false;
                });
            });
        })

    </script>
</block>